<extend name="layout/edit" />

<block name="HEADER">
	<style type="text/css">
		input[name='ranges']{
			padding-right: 28px !important;
		}
	</style>
</block>

<block name="CONTENT">
    <control:form id="termForm"/>
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
		ns.init = function(){
		
		}
		
		//获取优惠券
		ns.getCoupon = function(ids){
			var  coupon_id = form.getValue('coupon_id'); 
			$.ajaxs("/admin/v1/coupon_issue/getCoupon",{ 
				start_time: form.getValue('start_time'),
				ids: ids || ''
			},function(res){
				form.addOption("coupon_id", $.map(res.data,function(h){
					h.selected = String(ids || coupon_id || "").split(',').indexOf(String(h.id)) != -1; 
					return h;
				}));
				ns.getNum();
			});
		}
		
		ns.add = function(){
			var filter = {
	            url:"modules/lottery/edit",
	            oid:"",
	            mode:1
	        }
	        $.openIframe(filter, "新增",['750px', '580px']);
		}
		
        //保存
        ns.save=function(){
    		termForm.save(1).then(function(res){
            	termForm.opener.form.$grids['termGrid'].load();
            });
        }
        
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>



